<template>
  <div id="app">
      <router-view/>
  </div>
</template>
<script>
  import {mapState,mapMutations} from 'vuex'
export default {
  name: 'App',
  computed:{
    ...mapState({
      isExit:state=>state.app.loginState.isExit||sessionStorage.getItem('isExit'),
      user_id:state=>state.app.loginState.user_id||sessionStorage.getItem('user_id'),
      token:state=>state.app.loginState.token||sessionStorage.getItem('token'),
      user_name:state=>state.app.loginState.user_name||sessionStorage.getItem('user_name')
    })
  },
  methods:{
    ...mapMutations(['saveUid','changeLoginStatus','changeWidth']),
    exitFn(){
      this.axios.get('/api/v1/accout/userlogin')
        .then((res)=>{
          this.changeLoginStatus({
            isExit:0
          });
          this.saveUid({
            user_id:'',
            token:'',
            user_name:''
          })
          localStorage.setItem('user_id','')
          localStorage.setItem('user_name','')
          localStorage.setItem('token','');
          this.$router.push({
            path:'/'
          });
        })
    },
    init(){
      console.log(document.documentElement.clientHeight)
    },
    getDeviceWidth(){
        var height =document.documentElement.clientHeight||document.body.clientHeight;
        var width =document.documentElement.clientWidth||document.body.clientWidth;
        sessionStorage.setItem('width',width);
        sessionStorage.setItem('height',height-160);
        this.$store.commit('changeHeight',{
          height:(height-200)
        });
      this.$store.commit('changeWidth',{
        height:(height-200)
      });
    },
  },
  mounted(){
    this.init();
    this.getDeviceWidth();
    // window.onbeforeunload=function(){
    //     return '确定要离开吗？'
    // };
  },
  destroyed(){
    this.exitFn();
  }
};

</script>

<style>

#app {
  font-family: "Microsoft YaHei";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  height: 100%;
  /*background-color: #f1f1f1;*/
  z-index: 999;
}
  *{
    padding: 0;
    margin: 0;
  }
 .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner{
  background: #8bc34a;
  border-color: #8bc34a;
}
.el-checkbox__inner::after{
  left: 6px;
  width: 4px;
  height: 10px;
}
.el-checkbox__inner{
  width: 18px !important;
  height: 18px !important;
}
.fixedBottom{
  position: fixed;
  bottom: 30px;
  right: 46px;
  width: 56px;
  z-index: 998;
  /*height: 100%;*/

}
.fixedBottom .toTop{
  display: inline-block;
  width: 56px;
  height: 56px;
  margin-top: 10px;
}
.fixedBottom a{
  display: block;
  width: 56px;
  height: 56px;
  text-align: center;
  position: relative;
  background: white;
  border-radius: 3px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  cursor: pointer;
  box-shadow: 3px 3px 2px #f4f4f4;
}
.fixedBottom a.el-msg img{
  width: 36px;
  height: 31px;
  position: absolute;
  left: 0;
  top:0;
  right: 0;
  bottom: 0;
  margin: auto;
}
.fixedBottom a.el-msg cite{
  position: absolute;
  background: #f36b6b;
  width: 40px;
  height: 22px;
  border-radius: 10px;
  -webkit-border-radius: 10px;
  font-size: 12px;
  color: white;
  right: 0%;
  top:-12px;
  margin-right: -20px;
  line-height: 22px;
  font-style: normal;
}
.fixedBottom .toTop img{
  position: absolute;
  left: 0;
  top:0;
  right: 0;
  bottom: 0;
  margin: auto;
}
.fixedBottom .el-msg{
  padding:0;
  display: inline-block;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
}
.el-pagination{
  text-align: right;
  margin-top: 20px;
  margin-bottom: 20px;
  /*padding-right: 100px;*/
}
.el-pagination  .is-background .el-pager li:not(.disabled).active{
  background: #8bc34a ;
  color: white;
}
.el-pagination  .el-pager li{
  background:#eeeeee;
  border-radius: 2px;
  -webkit-border-radius: 2px;
  margin:0  4px;
  color: #a6a6a6;

}
.el-pagination  .el-pager li.active{
  background: #8bc34a !important;;
  color: white !important;;
}
 .el-pagination  button:disabled{
  background: #f4f4f5 !important;;
}
 .el-button--primary{
  background:#8cc34b;
  border-color: #8cc34b;
}
 .el-button--primary:focus, .el-button--primary:hover{
  background:#8cc34b;
  border-color: #8cc34b;
}
.el-button:focus, .el-button:hover {
  background-color: #a2cf6e;
}
.el-button--default:hover,.el-button--default:focus{
  background-color: #f3f9ed;
  color: #4e8c07;
}
  .e-delete-btn {
    border-color: #dbdbdb;
    background: white;
  }
  .el-dialog  .el-form .el-form-item{
    margin-bottom: 10px;
  }
.el-dialog   .el-input{
  width: 380px;
}
.el-dialog .el-form  .el-radio__input.is-checked .el-radio__inner{
  background: #8cc34b;
  border-color: #8cc34b;
}
.el-dialog .el-form  .el-radio__input.is-checked+.el-radio__label{
  color:#8cc34b;
}
.el-input.is-active .el-input__inner, .el-input__inner:focus{
  border-color: #8cc34b;
}
.el-select .el-input.is-focus .el-input__inner{
  border-color: #8cc34b;
}
.e-tips{
  position: fixed;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  left: 0;
  top:0;
  z-index: 998;
}
.e-tips  .e-tips-block{
  position: absolute;
  left: 0;
  top:0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: 300px;
  height: 80px;
  background: white;
  text-align: center;
  line-height: 80px;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
}
.e-tips  .e-tips-block span{
  font-size: 16px;
  color: #333;
  position: relative;
  padding-left: 30px;
}
.e-tips  .e-tips-block span:before{
  position: absolute;
  left: 0;
  content: '';
  top:50%;
  transform: translateY(-50%);
  -webkit-transform: translateY(-50%);
  -moz-transform: translateY(-50%) ;
  -ms-transform: translateY(-50%) ;
  -o-transform:  translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("../static/images/e-tips.png");
  background-size: 16px 16px;
  background-repeat: no-repeat;
}
#app .removeSort.is-required:not(.is-no-asterisk)>.el-form-item__label:before {
  content: '';
  color: #F56C6C;
  margin-right: 4px;
}
body .el-table th.gutter{
  display: table-cell!important;
}
</style>
